//
//  ViewController.m
//  UI07_UINavigationController
//
//  Created by Scott on 16/5/11.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecond.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor redColor];
    
    self.title = @"NEW";
    
    [self createSubView];
    [self configNavigationBar];
    [self configNavigationItem];
}

- (void)createSubView {
    
    
    UIView *viewOfGreen = [[UIView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:viewOfGreen];
    [viewOfGreen release];
    
    viewOfGreen.backgroundColor = [UIColor greenColor];
    
    // scrollView
    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:self.view.frame];
    scroll.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:scroll];
    [scroll release];
    
    UIView *viewOfYellow = [[UIView alloc] initWithFrame:scroll.bounds];
    
    viewOfYellow.backgroundColor = [UIColor yellowColor];
    [scroll addSubview:viewOfYellow];

}


#pragma mark - 知识点1: UINavigationBar
- (void)configNavigationBar {
    
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    
    // 颜色
//    self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
    
}

#pragma mark - 知识点2: UINavigationItem 
- (void)configNavigationItem {
    
    self.navigationItem.title = @"首页";
    
    // left
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(handleTrash:)];
    
    // right
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"shezhi"] style:UIBarButtonItemStylePlain target:self action:@selector(handleRight:)];
    
    
}

- (void)handleTrash:(UIBarButtonItem *)barButton {
    
    NSLog(@"ddd");
}

#pragma mark - 知识点3: NavigationController推出页面.
- (void)handleRight:(UIBarButtonItem *)barBtn {
    
    // 创建第二页对象.
    VCOfSecond *second = [[VCOfSecond alloc] init];
    
    // 压栈
    [self.navigationController pushViewController:second animated:YES];
    
    // 内存
    [second release];
    
    
}








@end
